package com.activenetwork.smlite.testcase.events.createEvents.basics;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import com.activenetwork.smlite.page.event.EventDetailView.EventBasicSubview;
import com.activenetwork.smlite.snippet.EventsSnippet;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.WaitUtil;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Basics017 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(Basics017.class);
	
	
	@Test
	public void Verify_multiple_tags_can_be_added_when_create_event(){
		loginBusiness.login();
		EventBasicSubview eventBasicSubview = EventsSnippet.gotoAddEventPage();
		
		// Select more than 10 tags from suggest list
		WaitUtil waitUtil = new WaitUtil();
		for(int i=1; i<=11; i++){
			eventBasicSubview = eventBasicSubview.selectEventTagAJAX("tag", i);
			waitUtil.wait(500);
		}
		
		// Verify there should only be 10 tags added
		// Verify the same tag will not display in the tag editbox again
		By by = By.cssSelector(".autotest-lookup-EventBasicSubview-event-tagsref .nexus-lookup>div[data-lookup-identifier]");
		List<WebElement> savedTags = webDriver.findElements(by);
		if(savedTags.size() != 11){
			EnvContext.failurePointTL.get().add(
					new FailurePoint(Basics017.class.getName(), 
					"Verify add more than 10 tags", 
					"Add 11 tags but less than 11 tags found on the event."));
		}
		
		loginBusiness.logout();
	}

}
